'''
Created on May 31, 2012

@author: mupet
'''
from syslogd.configuration.ConfReader import ConfReader
from syslogd.configuration.Configuration import Configuration
from syslogd.configuration.ConfParser import ConfParser
from syslogd.configuration.ConfWriter import ConfWriter
from syslogd.status.Status import Status

class ConfHolder(object):
    '''
    classdocs
    '''

    instance = None

    def __init__(self):
        '''
        Constructor
        '''
        ConfHolder.instance = self
        self.readConfiguration()
        
    def getList(self):
        return self.objectList
    
    def readConfiguration(self):
        self.cr = ConfReader(Configuration.getSyslogdConfigurationPath())
        self.cr.read()
        self.objectList = ConfParser.createConfObjects(self.cr.getList())
        
    def writeConfiguraiton(self):
        """TODO: uncomment to write configuratiotn to file !!
        ConfWriter.writeConf(Status, self.objectList)
        """

    @staticmethod
    def getInstance():
        if ConfHolder.instance is None:
            ConfHolder.instance = ConfHolder()
        return ConfHolder.instance
    
    